import { defineStore } from 'pinia';

export const useObsStore = defineStore('obs', () => {
  // 声明全局变量存储
  let obs: Record<string, any> = {};

  // 设置全局变量
  function setObs(key: string, value: any) {
    obs[key] = value;
  }

  // 获取全局变量
  function getObs(key: string) {
    return obs[key];
  }

  // 删除全局变量
  function deleteObs(key: string) {
    delete obs[key];
  }

  // 清空所有全局变量
  function clearObs() {
    obs = {};
  }

  // 获取所有全局变量
  function getAllObs() {
    return obs;
  }

  // 重置 store 状态
  function $reset() {
    obs = {};
  }

  return {
    setObs,
    getObs,
    deleteObs,
    clearObs,
    getAllObs,
    $reset,
  };
});


